*Replication file for cross-national analysis using Orbis historical data
*Unfortunately, the Orbis Historical data is pay-walled, and I am unable to share their data here. I have thus uploaded the data from public sources, which will then need to be merged with the Orbis Historical data after you obtain access to Orbis Historical. You will need to download the following variables from Orbis Historical and merge them with the cross-national data provided here: "employees", "fixedassets", "totalassets", "nacerev2corecode4digits", "iso2c","profitmargin", "plbeforetax", "plaftertax", "year". You need to merge on "iso2c" and "year". This merge will thus be from many to one (many firms in each country-year).

*The "mobility-orbis-data-share.dta" file includes all the publicly-available data that must be merged with the data from Orbis Historical.
use "mobility-orbis-data-share.dta"
*If you're coming from the Orbis Historical data file, several variables will need to be logged prior to the analysis: 
*gen logfixedassets = log(fixedassets)
*gen logtotalassets = log(totalassets)
*gen logemployees = log(numberofemployees)
*gen logprofitmargin = log(profitmargin)
*gen logplaftertax = log(plaftertax)
*gen logplbeforetax = log(plbeforetax)

*Below is the replication code.

*TABLE 2: Dependent variable is profit margin, logged
eststo reg1: reg logprofitmargin  i.year c.logfixedassets##c.wbgi_rle, robust cluster(ccode) 
eststo reg2: reg logprofitmargin  i.year c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg logprofitmargin i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg logprofitmargin  i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 
eststo reg5: reg logprofitmargin  i.year i.nace i.ccode c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 

estout reg1 reg2 reg3 reg4 reg5 , cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets $\times$ Rule of law" ///
		  _cons "Constant")
		  
set scheme plotplain


*FIGURE 6: Marginal effect of governance on profits
reg logprofitmargin  i.year i.nace i.ccode c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 
margins, dydx(wbgi_rle) at(logfixedassets =(0(3)33)) force
marginsplot, yline(0) xlabel(0(6)33) recast(line) ciopt(color(%10)) recastci(rarea) ///
         title("") ytitle("Marginal Effects of Rule of Law") xtitle("Fixed Assets (Logged)") ///
         addplot(hist logfixedassets, yaxis(2) yscale(range(0 .15) alt axis(2)) color(gray%30) ///
                 legend(off)     width(1))


				 
*********************
******APPENDIX*******	 
*********************


*TABLE A10: Effect of rule of law on profits, moderated by fixed assets; fixed assets is split into terciles
eststo reg1: reg logprofitmargin  i.year i.tercile##c.wbgi_rle, robust cluster(ccode) 
eststo reg2: reg logprofitmargin  i.year i.tercile##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg logprofitmargin i.year i.nace i.tercile##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg logprofitmargin  i.year i.nace i.tercile##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 
eststo reg5: reg logprofitmargin  i.year i.nace i.ccode i.tercile##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 

	estout reg1 reg2 reg3 reg4 reg5 , cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets $\times$ Rule of law" ///
		  _cons "Constant")				 

		  
*TABLE A11: Effect of rule of law on profits, moderated by fixed assets; fixed assets is split into quintiles
eststo reg1: reg logprofitmargin  i.year i.quintile##c.wbgi_rle, robust cluster(ccode) 
eststo reg2: reg logprofitmargin  i.year i.quintile##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg logprofitmargin i.year i.nace i.quintile##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg logprofitmargin  i.year i.nace i.quintile##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 
eststo reg5: reg logprofitmargin  i.year i.nace i.ccode i.quintile##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 

	estout reg1 reg2 reg3 reg4 reg5 , cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets $\times$ Rule of law" ///
		  _cons "Constant")

*TABLE A12: Effect of rule of law on profits, moderated by fixed assets and low- or high-levels of variation in mobility within industries
*To calculate lowvariationindustry, here is the code:
*egen SDfix = sd(logfixedassets), by(nace)
*egen SDfix_all = sd(logfixedassets)
*gen lowvariationindustry = 0
*replace lowvariation = 1 if SDfix<SDfix_all
*replace lowvariation = . if SDfix==.
eststo reg1: reg logprofitmargin  i.year c.logfixedassets##c.wbgi_rle##i.lowvariationindustry, robust cluster(ccode) 
eststo reg2: reg logprofitmargin  i.year c.logfixedassets##c.wbgi_rle##i.lowvariationindustry logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg logprofitmargin i.year i.nace c.logfixedassets##c.wbgi_rle##i.lowvariationindustry logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg logprofitmargin  i.year i.nace c.logfixedassets##c.wbgi_rle##i.lowvariationindustry logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 
eststo reg5: reg logprofitmargin  i.year i.nace i.ccode c.logfixedassets##c.wbgi_rle##i.lowvariationindustry logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2 kaopen, robust cluster(ccode) 

	estout reg1 reg2 reg3 reg4 reg5, cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets $\times$ Rule of law" ///
		  c.logfixedassets#c.wbgi_rle#1.lowvariationindustry "Fixed assets $\times$ Rule of law $\times$ Low variation" ///
		  c.logfixedassets#1.lowvariationindustry "Fixed assets $\times$ Low variation" ///
		  c.wbgi_rle#1.lowvariationindustry "Rule of law $\times$ Low variation" ///
		  kaopen "Capital account openness" ///
		  _cons "Constant")


*TABLE A13: Depdent variable is profit and loss ratio after tax
eststo reg1: reg logplaftertax  i.year c.logfixedassets##c.wbgi_rle, robust cluster(ccode) 
eststo reg2: reg logplaftertax  i.year c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg logplaftertax  i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg logplaftertax  i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2, robust cluster(ccode) 
eststo reg5: reg logplaftertax  i.year i.nace i.ccode c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2, robust cluster(ccode) 


	estout reg1 reg2 reg3 reg4 reg5 , cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets$\times$Rule of law" ///
		  _cons "Constant")


*TABLE A14: Dependent variable is profit margin		  
eststo reg1: reg profitmargin  i.year c.logfixedassets##c.wbgi_rle, robust cluster(ccode) 
eststo reg2: reg profitmargin  i.year c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg profitmargin  i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg profitmargin  i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2, robust cluster(ccode) 
eststo reg5: reg profitmargin  i.year i.nace i.ccode c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2, robust cluster(ccode) 

	estout reg1 reg2 reg3 reg4 reg5 , cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets$\times$Rule of law" ///
		  _cons "Constant")


*TABLE A15: Dependent variable is profit to loss ratio, before taxes		  
eststo reg1: reg logplbeforetax i.year c.logfixedassets##c.wbgi_rle, robust cluster(ccode) 
eststo reg2: reg logplbeforetax i.year c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg3: reg logplbeforetax i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets, robust cluster(ccode) 
eststo reg4: reg logplbeforetax i.year i.nace c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2, robust cluster(ccode) 
eststo reg5: reg logplbeforetax i.year i.nace i.ccode c.logfixedassets##c.wbgi_rle logemployees logtotalassets loggdppc_wdi wdi_gdpgr p_polity2, robust cluster(ccode) 

	estout reg1 reg2 reg3 reg4 reg5 , cells(b(star fmt(a2)) ///
		  se(par fmt(%4.3f))) starlevels( * .1 ** .05 *** .01) stats(N , fmt(%9.0gc)  labels("Number Obs." ))  ///
		  nolz style(tex) drop(*year  *ccode *nacerev2corecode4digits)   ///
		  varlabels(logfixedassets "Fixed assets, log" ///
		  wbgi_rle "Rule of law" ///
		  p_polity2 "Polity" icrg_qog "ICRG governance" ///
		  logtotalassets "Total assets, log" logemployees "Employees, log" ///
		  loggdppc_wdi "GDP per capita, log" wdi_gdpgr "GDP growth" ///
		  c.logfixedassets#c.wbgi_rle "Fixed assets $\times$ Rule of law" ///
		  _cons "Constant")
